<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'page2.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
	body{
		margin:0px 0px;
		padding:0px 0px;
		width: 100%;
		height: 100%;
		background-color: #eee8aa;
	}
</style>
	<script type="text/javascript" src="./js/jquery-1.8.2.js"></script></head>
  <p style="margin-top: 10px">可点击选择图片按钮修改:
  	<div class="top" style="padding-left: 50px">
	  	<c:forEach items="${req2}" var="r2" varStatus="v">
	  		${v.index+1}.
	  		<img alt="首页" src="/wifiIMG/icon/img1/${r2.pic}" height="50%" >
	  		<form action="${pageContext.request.contextPath}/Guan/GuanLiUrl_updateImgUrl.action" method="post" 
	  			enctype="multipart/form-data" onsubmit="return updateSub()">
			  	<input type="file" name="file" style="margin-left: 30px;border: solid 1px #8fbc8f;" />
			  	<input type = "hidden" name="type" id="type" value="1"/>
			  	<input type = "hidden" name="u.rid" value="${r2.rid}" id="ra${v.index}"/>
			  	<input type = "hidden" name="u.pic" value="${r2.pic}"  id="pica${v.index}"/>
			  	<input type = "hidden" name="u.id" value="${r2.id }" id="ia${v.index}"/>
			  	<input type = "hidden" name="u.page" value="${r2.page}" id="pa${v.index}"/>
			  	网址:<input type = "text" name="u.url" value="${ r2.url}" id="up_url"/>
			  	<input type="submit" value="保   存" style="padding-left: 25px;padding-right: 25px;">
			  	<input type="button" value="删除" title="点击删除" onclick="return shanchu(this.id)" id="a${v.index}"/>
		  	</form>
	  	</c:forEach>
	  	<hr>
	  	<p style="font-weight: 800" >添加:</p>
	  	<form action="${pageContext.request.contextPath}/Guan/GuanLiUrl_insertImgUrl.action" method="post" enctype="multipart/form-data" onsubmit="return insertSub()">
		  	<input type="file" name="file" style="margin-left: 30px;border: solid 1px #8fbc8f;" id="in_file"/>
		  	网址:<input type = "text" name="u.url" value="${ r2.url}" id="in_url"/>
	  		<input type = "hidden" name="type" id="type" value="1"/>
	  		<input type="hidden" name="u.rid" value="2"> 
	  		<input type="hidden" name="u.page" value="1"> 
	  		<input type="submit" value="添  加" style="padding-left: 25px;padding-right: 25px;">
	  	</form>
	  	<br>
	  	<br>
  	</div>
 	
  <body>
  <script type="text/javascript">
  	
  	 function insertSub(){
  	 	var file = $("#in_file").val();
  	 	var url = $("#in_url").val();
  	 	var time = $("#in_time").val();
  	 	if(file!=""&&url!=""&&time!=""){
  	 		return true;
  	 	}
  	 	alert("所有内容不能为空!");
  	 	return false;
 	}
 	  	function updateSub(){
  	 	var url = $("#up_url").val();
  	 	var time = $("#up_time").val();
  	 	if(url!=""&&time!=""){
  	 		return true;
  	 	}
  	 	alert("网址和显示时间不能为空!");
  	 	return false;
 	}
  	function shanchu(id){
 		var r=confirm("确定删除吗");
	  	  if (r==true){
 		 var uid = $("#i"+id).val();
 		 var rid = $("#r"+id).val();
 		 var page = $("#p"+id).val();
 		 var pic = $("#pic"+id).val();
 		
 		 var tpe = $("#type").val();
 			window.location.href="${pageContext.request.contextPath }/Guan/GuanLiUrl_deleteImgUrl.action?u.id="
 				+uid+"&u.rid="+rid+"&u.page="+page+"&type="+tpe+"&u.pic="+pic;
	    }
	   	return false;
 	}
  </script>
 
</html>
